# coding=utf-8
import json

from gridfs import GridFS
from pymongo import MongoClient

# 建立MongoDB数据库连接
client = MongoClient('localhost', 27017)

# 连接所需数据库,test为数据库名
db = client.wechat


def getCollection():
    collection = db.test
    return collection


def getGirdFsPipline():
    collection = db.files
    pipline = GridFS(collection)
    return pipline


if __name__ == '__main__':
    msg = ""
    msgObj = json.dumps(msg)
    collection = getCollection()
    collection.insert(msgObj)
